package com.learn.jdk;

import java.util.concurrent.ForkJoinPool;

/**
 * @author: lipan
 * @date: 2021/5/15 11:45
 */

public class ForkJoinPoolTest {


    private  static  int[] arr=new int[]{1,2,3,4,5,6,7,8,9,10};


    public static void main(String[] args) {

        System.out.println("result=>"+getSum(arr));

        ForkJoinPool forkJoinPool = new ForkJoinPool();

        AccumlatorRecursizeTask sumTask = new AccumlatorRecursizeTask(0,arr.length , arr);

        Integer  integer= forkJoinPool.invoke(sumTask);

        System.out.println(integer);


    }


     public static int getSum(int[] arr){

        int result=0;
         for (int i : arr) {
             result+=i;
         }

         return  result;
     }


}
